home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Determining the length of an int in string form
- Date: Mon, 18 Mar 96 15:32:23 GMT
- Organization: none
- Message-ID: <827163143snz@genesis.demon.co.uk>
- References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <DoE38u.GIH@iquest.net>
- dlmiller@iquest.net "Doug & Rose Miller" writes:
-
- >wkaufman@wkaufman.us.oracle.com (William Kaufman) wrote:
- >+In article <3146D058.DD7@cbm.com> Dave Payne <paynedc@cbm.com> writes:
- >+] Consider this:
- >+]
- >+] I have a variable of type int, and I would like to use the sprintf()
- >+] function to write this variable to a string. However, I want to
- >+] dynamically allocate the space for the string, and only malloc enough
- >+] space to hold the int.
- >
- >WHY ???
- >
- >Even a 32-bit int is only 9 characters at most, and that's *with* the sign.
-
- -2147483647 is a valid 32 bit int and is 11 characters (excluding the null
- character string terminator). The problem of course is that ints aren't
- limited to 32 bits - the language imposes no upper limit to their size.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-